mod actor_system;
mod context;
mod message;
mod mailbox;
mod actors;

use std::sync::{Arc, Mutex};
use actor_system::ActorSystem;
use actors::hello_actor::HelloActor;
use message::Hello;
use mailbox::{MailboxType, QueueType};

#[tokio::main]
async fn main() {
    // 创建 Actor 系统
    let system = ActorSystem::new();

    // 创建 HelloActor
    let hello_actor = Arc::new(Mutex::new(HelloActor));

    // 启动 HelloActor，使用无界 flume mailbox
    let actor_id = system.spawn(hello_actor, MailboxType::Unbounded, QueueType::Flume);

    // 发送消息
    system.send(actor_id, Box::new(Hello { who: "Protoactor-rs".to_string() })).await;

    // 等待输入以保持程序运行
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
}
